package com.exchange.controller;

import com.exchange.config.KettleHelper;
import com.exchange.config.RabbitmqConfig;
import com.exchange.utils.result.CommonResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.pentaho.di.core.exception.KettleException;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.*;

@RestController
@RefreshScope
@RequestMapping("/kettle/rabbitmq")
@Api(value = "消息中间件", tags = "消息中间件")
public class RabbitMqController {

    @Autowired
    private RabbitTemplate rabbitTemplate;

    @GetMapping("/sendJobMsg")
    @ApiOperation("发送作业消息")
    public CommonResult sendJobMsg(@RequestParam("jobName") String jobName)  {
        rabbitTemplate.convertAndSend(RabbitmqConfig.EXCHANGE_TOPICS_INFORM,"inform.job",jobName);
        return CommonResult.success("成功!");
    }

    @GetMapping("/sendTransMsg")
    @ApiOperation("发送转换消息")
    public CommonResult sendTransMsg(@RequestParam("transName") String transName) {
        rabbitTemplate.convertAndSend(RabbitmqConfig.EXCHANGE_TOPICS_INFORM,"inform.trans",transName);
        return CommonResult.success("成功!");
    }

}
